<?php
error_reporting(NULL);
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
	//print_r($_POST);
	$targ_w = 300;
	$targ_h = 350;
	$jpeg_quality = 100;
	$src = "../".$_REQUEST['crop_image_src'];
	$img_r = imagecreatefromjpeg($src);
	$dst_r = ImageCreateTrueColor( $targ_w, $targ_h );
	$dest = "product/cropped.jpg";
	imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'], $targ_w,$targ_h,$_POST['w'],$_POST['h']);
	header('Content-type: image/jpeg');
	imagejpeg($dst_r,"../".$dest,$jpeg_quality);
	echo $dest;
}
?>